<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!-- 分页信息。该页面用于所有的公共分页 -->

<br/>
共有${paginator.totalNum}条记录，共${paginator.totalPage}页，每页显示${paginator.pageNum}条。 当前显示${paginator.beginNum+1}-${paginator.endNum}条记录，每页显示
	<select name="pageSize">
		<option value="10" <c:if test="${paginator.pageNum eq 10}">selected</c:if>>10条</option>
		<option value="20" <c:if test="${paginator.pageNum eq 20}">selected</c:if>>20条</option>
		<option value="40" <c:if test="${paginator.pageNum eq 40}">selected</c:if>>40条</option>
	</select>

	<a href="#" onclick="gotoPage(${paginator.nextPage})">|<< </a>
	<a href="#" onclick="gotoPage(${paginator.totalPage})"><</a>
	<c:forEach items="${paginator.listPage}" var="item">
		<a href="#" onclick="gotoPage(${item})">${item}</a>
	</c:forEach>
	<a href="#" onclick="gotoPage(${paginator.nextPage})">></a>
	<a href="#" onclick="gotoPage(${paginator.totalPage})">>>|</a>
	
	<input type="hidden" id="page" name="page"/>
	<input type="text" id="gotopage" name=""/>

	<input type="button"
		onclick="gotoPage(document.getElementById('gotopage').value)" value="Go" />

	<script>
		/**
		*页面跳转 
		*/
		function gotoPage(page){
		alert(page)
			if(checkPage(page)){
				document.getElementById("page").value = page;
				document.getElementById("current_form").submit;
			}
			document.getElementById("page").value = page;
			document.getElementById("current_form").submit;
		}
		/**
		*检查跳转到的页面数值是否正确
		*/
		function checkPage(page){
			var beginPage = ${paginator.totalPage};
			if(page>beginPage){
				alert("超过最大页");
				return false;
			}
			if(0>page){
				alert("页数必须为正数");
				return false;
			}
			return true;
		}
	</script>
